package com.howinfun.common;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;

/**
 * @author stephen
 * @date 2019/1/10
 * @desc 公共返回值(PS：依赖lombok)
 */

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> implements Serializable {
    private static final Integer SUCCESS = 0;
    private static final Integer FAIL = 1;
    private Integer code = Result.SUCCESS;
    private String msg = "success";
    private T data;

    public static Result ok(String msg){
        Result ok = new Result();
        ok.setMsg(msg);
        return ok;
    }

    public static Result error(String msg){
        Result error = new Result();
        error.setCode(Result.FAIL);
        error.setMsg(msg);
        return error;
    }
}
